
using UnityEngine;

public class EventDispatcherBehaviour : MonoBehaviour
{
	private EventDispatcher mEventDispatcher = new EventDispatcher();
	
	static public EventDispatcherBehaviour Get (GameObject go)
	{
		EventDispatcherBehaviour dispatcher = go.GetComponent<EventDispatcherBehaviour>();
		if (dispatcher == null) dispatcher = go.AddComponent<EventDispatcherBehaviour>();
		return dispatcher;
	}
	
	public void addEventListener (string astrEventName, EventHandler listener){
		mEventDispatcher.addEventListener(astrEventName, listener);
	}
	
	public void removeEventListener (string astrEventName, EventHandler listener){
		mEventDispatcher.removeEventListener(astrEventName, listener);
	}
	
	public bool dispatchEvent (BaseEvent e){
		return mEventDispatcher.dispatchEvent(e);
	}
	
	public bool hasEventListener (string astrEventName){
		return mEventDispatcher.hasEventListener(astrEventName);
	}
}